import { IFeidaoAiWeappPage } from '@dfeidao/atom-wxapp/interfaces';
import get_local from '@dfeidao/atom-wxapp/local/get';
import set_local from '@dfeidao/atom-wxapp/local/set';
import render from '@dfeidao/atom-wxapp/render/render';

export default async function a004(fd: IFeidaoAiWeappPage, e: {
	currentTarget: {
		dataset: {
			num: number,
			index: string
		}
	}
}) {
	// todo
	console.log('------args-a004-----', e);
	const dataArray = get_local(fd, 'dataArray') as any[];
	const num = e.currentTarget.dataset.num;
	const i = e.currentTarget.dataset.index;
	const key = 'dataArray[' + i + '].out_inv_qty';
	const param = {};
	param[key] = dataArray[i].out_inv_qty === num ? num - 1 : num;
	console.log(param);
	render(fd,
		param
	)
	dataArray[i].out_inv_qty = param[key];
	set_local(fd, 'dataArray', dataArray);
}
